#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5;
const int M = 1e9 + 7;

int k;
string a, b;

ll trans(string s, int k) {
    ll base = 1, res = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        res += base * (s[i] - '0');
        base *= k;
    }
    return res;
}
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> k >> a >> b;

    ll x = trans(a, k), y = trans(b, k);
    cout << x * y << endl;
    return 0;
}